cmake_minimum_required(VERSION 3.5)

project(MyToDesk_Client LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more information.
# They need to be set before the find_package(Qt5 ...) call.

#if(ANDROID)
#    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
#    if (ANDROID_ABI STREQUAL "armeabi-v7a")
#        set(ANDROID_EXTRA_LIBS
#            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
#            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
#    endif()
#endif()

find_package(Qt5 COMPONENTS Widgets LinguistTools REQUIRED)

#导入cuda环境
find_package(CUDA REQUIRED)
message(STATUS "CUDA_DIR = ${CUDA_DIR}")
message(STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}")
message(STATUS "CUDA_LIBRARIES = ${CUDA_LIBRARIES}")
include_directories(${CUDA_INCLUDE_DIRS})
link_directories(/usr/local/lib)

# 导入protobuf环境
include_directories(/usr/include)
link_directories(/usr/local/lib)


if(ANDROID)
  add_library(MyToDesk_Client SHARED
      main.cpp
      MainWindow.cpp
      MainWindow.h
      ShowFrameOpenGLWidget.h
      ShowFrameOpenGLWidget.cpp
      MainWindow.ui
      Login.cpp
      Login.h
      Login.ui
      RemoteCtlWidget.cpp.cpp
      RemoteCtlWidget.h
      RemoteCtlWidget.ui
      Global.h
      Global.cpp
      Client/HSocket.h
      Client/HSocket.cpp
      Client/RemoteClient.cpp
      Client/RemoteClient.h
      Client/SendFrameClient.cpp
      Client/SendFrameClient.h
      Client/RecFrameServer.cpp
      Client/RecFrameServer.h
      Domain/ClientMsg/MainMsg.pb.cc
      Domain/ClientMsg/MainMsg.pb.h
      Domain/ClientMsg/RemoteCtlMsg.pb.cc
      Domain/ClientMsg/RemoteCtlMsg.pb.h
      Domain/ClientMsg/LoginMsg.pb.cc
      Domain/ClientMsg/LoginMsg.pb.h
      Domain/SendFrameClientMsg/FrameMsg.pb.cc
      Domain/SendFrameClientMsg/FrameMsg.pb.h
      DataEncoding/DataEncoding.cpp
      DataEncoding/DataEncoding.h
      DataDecoding/DataDecoding.cpp
      DataDecoding/DataDecoding.h
      DataCollect/DataCollect.cpp
      DataCollect/DataCollect.h
      DataCollect/CudaService/CudaRGB32ToYUV444Service.cu
      DataCollect/CudaService/CudaRGB32ToYUV444Service.h
      CommonUtils/ClientUtils.cpp
      CommonUtils/ClientUtils.h
      CommonUtils/YUVStream.cpp
      CommonUtils/YUVStream.h
      CommonUtils/EncodeStream.cpp
      CommonUtils/EncodeStream.h
      CommonUtils/ThreadPool/HzThreadPool.cpp
      CommonUtils/ThreadPool/HzThreadPool.h
  )
else()
  cuda_add_executable(MyToDesk_Client
    main.cpp
    MainWindow.cpp
    MainWindow.h
    MainWindow.ui
    Login.cpp
    Login.h
    Login.ui
    ShowFrameOpenGLWidget.h
    ShowFrameOpenGLWidget.cpp
    RemoteCtlWidget.cpp
    RemoteCtlWidget.h
    RemoteCtlWidget.ui
    Global.h
    Global.cpp
    Client/HSocket.h
    Client/HSocket.cpp
    Client/RemoteClient.cpp
    Client/RemoteClient.h
    Client/SendFrameClient.cpp
    Client/SendFrameClient.h
    Client/RecFrameServer.cpp
    Client/RecFrameServer.h
    Domain/ClientMsg/MainMsg.pb.cc
    Domain/ClientMsg/MainMsg.pb.h
    Domain/ClientMsg/RemoteCtlMsg.pb.cc
    Domain/ClientMsg/RemoteCtlMsg.pb.h
    Domain/ClientMsg/LoginMsg.pb.cc
    Domain/ClientMsg/LoginMsg.pb.h
    Domain/SendFrameClientMsg/FrameMsg.pb.cc
    Domain/SendFrameClientMsg/FrameMsg.pb.h
    DataEncoding/DataEncoding.cpp
    DataEncoding/DataEncoding.h
    DataDecoding/DataDecoding.cpp
    DataDecoding/DataDecoding.h
    DataCollect/DataCollect.cpp
    DataCollect/DataCollect.h
    DataCollect/CudaService/CudaRGB32ToYUV444Service.cu
    DataCollect/CudaService/CudaRGB32ToYUV444Service.h
    CommonUtils/ClientUtils.cpp
    CommonUtils/ClientUtils.h
    CommonUtils/YUVStream.cpp
    CommonUtils/YUVStream.h
    CommonUtils/EncodeStream.cpp
    CommonUtils/EncodeStream.h
    CommonUtils/ThreadPool/HzThreadPool.cpp
    CommonUtils/ThreadPool/HzThreadPool.h
  )
endif()

target_link_libraries(MyToDesk_Client  Qt5::Widgets)
target_link_libraries(MyToDesk_Client -lX11)
target_link_libraries(MyToDesk_Client -lavformat)
target_link_libraries(MyToDesk_Client -lavcodec)
target_link_libraries(MyToDesk_Client -lavutil)
target_link_libraries(MyToDesk_Client -lprotobuf)
target_link_libraries(MyToDesk_Client -lpthread)
source_group("Client" FILES
    Client/HSocket.cpp
    Client/HSocket.h
    Client/RemoteClient.cpp
    Client/RemoteClient.h
    Client/SendFrameClient.cpp
    Client/SendFrameClient.h
    Client/RecFrameServer.cpp
    Client/RecFrameServer.h)
source_group("Domain/ClientMsg" FILES
    Domain/ClientMsg/MainMsg.pb.cc
    Domain/ClientMsg/MainMsg.pb.h
    Domain/ClientMsg/RemoteCtlMsg.pb.cc
    Domain/ClientMsg/RemoteCtlMsg.pb.h
    Domain/ClientMsg/LoginMsg.pb.cc
    Domain/ClientMsg/LoginMsg.pb.h
    )
source_group("Domain/SendFrameClientMsg" FILES
    Domain/SendFrameClientMsg/FrameMsg.pb.cc
    Domain/SendFrameClientMsg/FrameMsg.pb.h
    )
source_group("DataEncoding" FILES
    DataEncoding/DataEncoding.cpp
    DataEncoding/DataEncoding.h
    )
source_group("DataDecoding" FILES
    DataDecoding/DataDecoding.cpp
    DataDecoding/DataDecoding.h
    )

source_group("DataCollect" FILES
    DataCollect/DataCollect.cpp
    DataCollect/DataCollect.h
    )
source_group("DataCollect/CudaService" FILES
    DataCollect/CudaService/CudaRGB32ToYUV444Service.cu
    DataCollect/CudaService/CudaRGB32ToYUV444Service.h
    )
source_group("CommonUtils" FILES
    CommonUtils/ClientUtils.cpp
    CommonUtils/ClientUtils.h
    CommonUtils/YUVStream.cpp
    CommonUtils/YUVStream.h
    CommonUtils/EncodeStream.cpp
    CommonUtils/EncodeStream.h
    )
source_group("CommonUtils/ThreadPool" FILES
    CommonUtils/ThreadPool/HzThreadPool.cpp
    CommonUtils/ThreadPool/HzThreadPool.h
    )
